import u from "../utils";
import {FILLIN} from "../constants";
import fetch from "../utils/fetch";

const _api = u.api(FILLIN);
const _fetch = fetch(FILLIN);

export default {
  getPageInfo: (shortkey, oauthKey, makeUp, pageParams) => _api('getPageInfo', { data: { key: shortkey, oauthKey: oauthKey, makeUp, pageParams} }),
  getDataInfo: (shortkey, id, authorization_str) => _api(`data/${id}`, { data: { key: shortkey, authorization_str }, ignoreError: true}),
  submit: data => {
    return _api('submit', {
      type: 'post',
      data: data
    });
  },
  getThirdPartyConfig: (key, url) => _api('jssdk', {
    type: 'post',
    data: { key, url },
  }),
  getRules: shortkey => _api('rules', { data: { key: shortkey } }),
  check: (shortkey, oauthKey) => _api('check',{ data: { key: shortkey, oauthKey: oauthKey }, ignoreError: true }),
  uploadFile: data => {
    return _fetch('uploadFile', {
      method: 'post',
      body: data
    });
  },
  modifyRemark: data => {
    return _api('modifyRemark', {
      type: 'post',
      data: data
    });
  },
  modifyData: data => {
    return _api('modify', {
      type: 'post',
      data: data
    });
  },
  genOauthKey: code => _api('genOauthKey', { data: { oauthCode: code } }),

  //获取手机图形验证码图片
  getImageCaptch: data => _api('captcha/generate',{data: data}),

  //校验手机图形验证码
  checkImageCaptch: data => _api('captcha/verify',{
    type: 'post',
    data: data
  }),
  
  //发送短信
  sendSms: data => _api('sms', {
    type: 'post',
    data: data
  }),
  getCurrUser: () => _api('currUser'),
  fakeSSO: () => _api('fakeSSO', { ignoreError: true }),
  getMakeUpDate: (shortkey) => _api('makeUpDate', { data: { key: shortkey } })
}
